<template>
  <div class="cunluo" v-if="cunluoData.length">
    <div class="cunluo_top">
      <div class="cunluo_top_text">
        村落
      </div>
    </div>
    <div class="table">
      <el-table
        :data="tableDatas"
        border
        height="340"
        style="width: 100%; margin-top: 10px;"
        row-key="id"
        default-expand-all
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      >
        <el-table-column
          align="center"
          label="序号"
          type="index"
          sortable
          min-width="80"
        >
        </el-table-column>
        <el-table-column
          prop="town.value"
          min-width="50px"
          align="center"
          label="镇"
        >
        </el-table-column>
        <el-table-column
          prop="xzVillage.value"
          align="center"
          min-width="50px"
          label="行政村"
        >
        </el-table-column>
        <el-table-column
          prop="zrVillage.value"
          align="center"
          min-width="45px"
          label="自然村"
        >
        </el-table-column>
        <el-table-column
          prop="house.value"
          align="center"
          min-width="35px"
          label="户数"
        >
        </el-table-column>
        <el-table-column
          prop="people.value"
          align="center"
          min-width="35px"
          label="户籍人口"
        >
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      // 获取到表格的数据
      tableDatas: [
        {
          house: {
            key: "1-1",
            value: 1,
          },
          people: {
            key: "1-2",
            value: 2,
          },
          town: {
            key: "1-3",
            value: "1-3",
          },
          xzVillage: {
            key: "1-4",
            value: "1-4",
          },
          zrVillage: {
            key: "1-5",
            value: "1-5",
          },
        },
      ],
    };
  },
  methods: {
    // 接口请求村落数据
    getCunluoData() {
      console.log(this.cunluoData,"cunluoData的数据");
      this.cunluoData.forEach(item => {
        if(item.house.value == null || item.house.value == 0){
          item.house.value = '暂无数据'
        }
        if(item.people.value == null || item.people.value == 0){
          item.people.value = '暂无数据'
        }
        
        // console.log(item,"村落的item");
      });
      this.tableDatas = this.cunluoData;
    },
    rounding(row, colum) {
      return parseFloat(row[colum.property]).toFixed(2);
    },
    rounding1(row, colum) {
      return parseFloat(row[colum.property]).toFixed(1);
    },
  },
  computed: {
    ...mapState("Sjsx", ["cunluoData"]),
  },
  watch: {},
  mounted() {
    this.getCunluoData();
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-table,
// .el-table__body-wrapper{
//   height: 340px !important; 
// }
::v-deep .el-table__expanded-cell {
  background-color: rgba(14, 85, 238, 0.109) !important;
  border: 1px solid #466393cc;
}
::v-deep .el-table__body-wrapper {
  height: 280px !important;
}
// 滚动条的宽度
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  border-radius: 10px;
        background: linear-gradient(
        180deg,
        rgba(131, 166, 166, 0.1),
        rgba(131, 166, 166, 0.8),
        rgba(131, 166, 166, 0.1)
      );
}
// 滚动条里面的轨道(即背景颜色)
::v-deep .el-table__body-wrapper::-webkit-scrollbar-track{
      background-color: rgba(41,71,89,0.4);
}
::v-deep .el-table__header th,
::v-deep .el-table__header tr {
  // background-color: #17B3A3;
  color: #fff;
}
::v-deep .el-table th,
::v-deep .el-table tr,
::v-deep .el-table td {
  background-color: rgba(251, 251, 251, 0.109) !important;

  border: 0px solid #466393cc;
}
::v-deep .el-table__expand-icon {
  color: #fff;
}
/* 去掉中间数据的分割线 */
::v-deep .el-table__row > td {
  // border: 1px solid #466393cc;
}
/* 去掉上面的线 */
::v-deep .el-table th.is-leaf {
  // border: 1px solid #466393cc;
}
/* 去掉最下面的那一条线 */
::v-deep .el-table::before {
  height: 0px;
}
::v-deep .el-table__body tr {
  background-color: transparent !important;

  border: 1px solid #466393cc;
}
// .el-table__body tr:hover > td {
//     background-color: transparent !important;

//     border: 0px solid #134087;
// }
::v-deep .el-table td.el-table__cell,
::v-deep .el-table th.el-table__cell.is-leaf {
  border-bottom: 1px solid #466393cc;
  border-left: 1px solid #466393cc;
  font-size: 18px;
}
::v-deep .el-table--border th.el-table__cell.gutter:last-of-type{
  border-bottom: 1px solid #466393cc;
}
::v-deep .el-table--border .el-table__cell,
::v-deep
  .el-table__body-wrapper
  .el-table--border.is-scrolling-left
  ~ .el-table__fixed {
  border-right: 0px solid #ebeef5;
  color: #fff;
}
::v-deep .el-table--border::after,
::v-deep .el-table--group::after,
::v-deep .el-table::before {
  content: "";
  position: absolute;
  background-color: #466393cc; 
  z-index: 1;
}
::v-deep .el-table th.el-table__cell>.cell{
    padding-left: 5px;
    padding-right: 5px;
}
.cunluo {
  margin-bottom: 35px;
  .cunluo_top {
    background: url("../../../../../assets/images/home/top.png");
    // width: 440px;
    background-size: cover;
    margin-top: 10px;
    .cunluo_top_text {
      padding-left: 16px;
      font-family: OPPOSans;
      font-style: normal;
      font-weight: normal;
      font-size: 20px;
      line-height: 24px;
      /* identical to box height */
      color: #ffffff;
    }
  }
}
</style>
